#include <InetConstants.au3>
#include <Common.au3>

Opt("TrayIconHide", 1)
Global $CheckServiceSwitch = 1 ;
;检测飞狐服务是否可用
;服务可用： 返回1
;服务不可用：返回 0 @error 1.读取端口异常，2.服务不可用
Func _CheckService()
	Local $port = _GetTomcatPort()
	If Not $port Then
		Return SetError(1, 0, 0)
	EndIf
	InetRead("http://127.0.0.1:" & $port, $INET_FORCERELOAD)
	If @error Then
		Return SetError(2, 0, 0)
	Else
		Return SetError(0, 0, 1)
	EndIf
EndFunc   ;==>_CheckService

While 1
	Local $temp = ConsoleRead()
	If @error == 0 And @extended Then
		$CheckServiceSwitch = Int($temp)
	EndIf
	If $CheckServiceSwitch Then
		Local $bool = _CheckService()
		ConsoleWrite($bool)
		Sleep(1000)
	EndIf

WEnd
